/*
 * Part.java
 *
 */
package com.sun.demo.addressbook;

/**
 *
 */
public class Part {
    private String partName;
    private boolean isSpeakingPart;
    private boolean isSingingPart;
    private String notes;
    private int id;
    
    private static final int PRIMENO = 37;
    
    /**
     * Creates a new instance of Part
     */
    public Part() {
    }
    
    public Part(String partName, boolean isSpeakingPart, boolean isSingingPart, String notes) {
        this(partName, isSpeakingPart, isSingingPart, notes, -1);
    }

    public Part(String partName, boolean isSpeakingPart, boolean isSingingPart, String notes, int id) {
        this.setPartName(partName);
        this.setIsSpeakingPart(isSpeakingPart);
        this.setIsSingingPart(isSingingPart);
        this.setNotes(notes);
        this.setId(id);
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public int getId() {
        return id;
    }
    
    public void setPartName(String partName) {
        this.partName = partName;
    }
    
    public String getPartName() {
        return partName;
    }
    
    public void setIsSpeakingPart(boolean isSpeakingPart) {
        this.isSpeakingPart = isSpeakingPart;
    }
    
    public boolean getIsSpeakingPart() {
        return isSpeakingPart;
    }
    
    public void setIsSingingPart(boolean isSingingPart) {
        this.isSingingPart = isSingingPart;
    }
    
    public boolean getIsSingingPart() {
        return isSingingPart;
    }
    
    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public int hashCode() {
        int value = 1;
        value = value*PRIMENO + (partName == null ? 0 : partName.hashCode());
        
        // don't use the id since this is generated by db
        return value;
    }
    
    public boolean equals(Object other) {
        boolean bEqual = false;
        if (this == other) {
            bEqual = true;
        } else if (other instanceof Address) {
            Address thatPart = (Address) other;
/*            if ((lastName == null ? thatPart.lastName == null : lastName.equalsIgnoreCase(thatPart.lastName)) &&
                    (firstName == null ? thatPart.firstName == null : firstName.equalsIgnoreCase(thatPart.firstName)) &&
                    (middleName == null ? thatPart.middleName == null : middleName.equalsIgnoreCase(thatPart.middleName)) &&
                    (phone == null ? thatPart.phone == null : phone.equalsIgnoreCase(thatPart.phone)) &&
                    (email == null ? thatPart.email == null : email.equalsIgnoreCase(thatPart.email)) &&
                    (address1 == null ? thatPart.address1 == null : address1.equalsIgnoreCase(thatPart.address1)) &&
                    (address2 == null ? thatPart.address2 == null : address2.equalsIgnoreCase(thatPart.address2)) &&
                    (city == null ? thatPart.city == null : city.equalsIgnoreCase(thatPart.city)) &&
                    (state == null ? thatPart.state == null : state.equalsIgnoreCase(thatPart.state)) &&
                    (postalCode == null ? thatPart.postalCode == null : postalCode.equalsIgnoreCase(thatPart.postalCode)) &&
                    (country == null ? thatPart.country == null : country.equalsIgnoreCase(thatPart.country))) {
                // don't use id in determining equality
 */               
                bEqual = true;
//            }
        }
        return bEqual;
    }
}
